package leecode

func combineLCR(n int, k int) [][]int {
	arr := make([]int, n)
	for i := 1; i <= n; i++ {
		arr[i-1] = i
	}
	var result [][]int
	path := make([]int, 0)
	var backtracking func(arr []int, startIndex int)
	backtracking = func(arr []int, startIndex int) {
		if len(path) == k {
			temp := make([]int, len(path))
			copy(temp, path)
			result = append(result, temp)
			return
		}
		for i := startIndex; i < len(arr); i++ {
			path = append(path, arr[i])
			backtracking(arr, i+1)
			path = path[:len(path)-1]
		}
	}
	backtracking(arr, 0)
	return result
}
